<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>注册</title>
  <link rel="stylesheet" href="./zc.css">
  <script src="./02ajax.js"></script>
  
</head>
<body>
  <footer>
    <div class="aa" >
      <p>会员注册</p>
      <span>已注册<a href="./dl.html">直接登录</a></span>
      
    </div>
<!-- 密码由8-20位组成,数字和符号组成 -->
    <div class="bb" >
      <input type="text"  placeholder="请输入手机号" ><br>
      <input type="password"  placeholder="密码" ><br>
      <input type="password"  placeholder="请再次输入密码" > <br>
      <input type="button" value="注册" >
      <br>
      <p></p>
      <input type="checkbox" class="qq" >我已阅读并接受以下条款：<a
          href="https://h5rsc.vip.com/h5rscSupportClause/h5rscSupportClause/index.html"
          >《唯品会服务条款》</a
        ><br />
        <a href="https://www.vip.com/privacy">《唯品会基本功能隐私政策》</a
        ><br />


    </div>
  </footer>
  <!-- <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.5/axios.js"></script> -->
 axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
  <script>
  
    const baseUrl ="http://localhost:8888";
    let p = document.querySelector("p")
    let inp= document.querySelectorAll("input");
    inp[inp.length-1].onclick=function(){

      let params = {
          username: inp[0].value,
          password: inp[1].value,
          rpassword:inp[2].value,
          nickname: inp[3].value, 
      };

      ajax({
        url:baseUrl + "/users/register",
        type:"post",
        params,
        fn(resData){
          resData=JSON.parse(resData);
          if(inp[4]==true){
            if (resData.code==0) {
              p.innerHTML= "注册失败";
            }if(resData.code==1){
              location.href= "dl.html";
            }
          }else{
            p.innerHTML= "请同意"
          };

        }
            })


    };
     
           
             
            
 
          
    </script>
</body>
</html>